<template>
  <div class="white-box">
    <div class="table-mb">
      <el-button type="primary" @click="handleAdd()" :icon="CirclePlus">添加商品</el-button>
    </div>

    <div class="task-one">
      <div class="task-one__item">
        <span class="task-one__label">名称：</span>
        <el-input placeholder="请输入名称" v-model="searchParams.pianqu_title" @keyup.enter.native="handleSearch"
                  clearable></el-input>
      </div>
      <div class="task-one__item">
        <span class="task-one__label">名称：</span>
        <el-input placeholder="请输入名称" v-model="searchParams.pianqu_title" @keyup.enter.native="handleSearch"
                  clearable></el-input>
      </div>
      <div class="task-one__item">
        <span class="task-one__label">名称：</span>
        <el-input placeholder="请输入名称" v-model="searchParams.pianqu_title" @keyup.enter.native="handleSearch"
                  clearable></el-input>
      </div>
      <div class="task-one__btn task-wrap-btn clearfix">
        <el-button type="primary" :loading="searchBtnLoading" :icon="Search" @click="handleSearch">搜索</el-button>
        <el-button type="success" @click="importData('admin/order/rentOrder/export',searchParams)" :icon="Download">导出</el-button>
      </div>
    </div>

    <el-tabs v-model="tabsActive" type="card" >
      <el-tab-pane label="全部（856）" name="all"></el-tab-pane>
      <template v-for="(item, index) in selectOptions.status">
        <el-tab-pane :label="item.label" :name="item.value"></el-tab-pane>
      </template>
    </el-tabs>

    <div style="margin-bottom: 10px">
      <span style="margin-right: 20px">已选：0</span>
      <el-button plain size="small"  @click="">批量删除</el-button>
      <el-button plain size="small"  @click="">批量上架</el-button>
      <el-button plain size="small"  @click="">批量下架</el-button>
    </div>

    <el-table class="table-mb" v-loading="loading" :data="list" :header-cell-style="{ background: '#F5F7FA' }"
              element-loading-background="rgba(255, 255, 255, 0.6)" @selection-change="handleAllSelected">
      <el-table-column type="selection" width="55" />
      <el-table-column prop="主图" label="商品" min-width="80" width="80">
        <template #default="{ row }">
          <el-image style="width: 65px; height: 65px; border: 1px solid rgb(204, 204, 204); padding: 3px; border-radius: 5%;" src="https://imgzh.kmmyxb.cn/gallery/5003413bd9aa34137c573314a5fa1dc4_1.png!img_200" fit="cover" />
        </template>
      </el-table-column>
      <el-table-column prop="title" label="商品" min-width="260">
        <template #default="{ row }">
          <p >抗衰系列</p>
          <p ><span style="text-decoration: line-through;">￥0.01</span>&nbsp;&nbsp;<span  style="font-weight: 700;">￥0.01</span></p>
          <p >库存：99件</p>
          <p >分类：品项商品,分红商品1</p>
        </template>
      </el-table-column>
      <el-table-column prop="visible" label="编号"  width="100">
        <template #default="{ row }">
          <span>450100</span>
        </template>
      </el-table-column>
      <el-table-column prop="visible" label="状态"  width="100">
        <template #default="{ row }">
          <span>已上架</span>
        </template>
      </el-table-column>
      <el-table-column prop="visible" label="总销量"  width="100">
        <template #default="{ row }">
          <span>705</span>
        </template>
      </el-table-column>
      <el-table-column prop="visible" label="排序"  width="100">
        <template #default="{ row }">
          <span>705</span>
        </template>
      </el-table-column>
      <el-table-column prop="created_at" label="创建时间" width="160">
        <template #default="{ row }">
          <span>2024-12-18 19:51:45</span>
        </template>
      </el-table-column>
      <el-table-column prop="created_at" label="更新时间" width="160">
        <template #default="{ row }">
          <span>2024-12-18 19:51:45</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="200" width="200" fixed="right">
        <template #default="{ row }">
          <div style="margin-bottom: 6px">
            <el-button class="action-btn" size="small" plain type="primary" @click="toGoodsEdit(row)">编辑</el-button>
            <el-button class="action-btn" size="small" plain type="primary" @click="">复制</el-button>
          </div>
          <div style="margin-bottom: 6px">
            <el-button class="action-btn" size="small" plain type="warning" @click="">审核</el-button>
            <el-button class="action-btn" size="small" plain type="warning" @click="">上架</el-button>
          </div>
          <div>
            <el-popconfirm :persistent="false" title="确定删除吗？" confirm-button-text="确定" cancel-button-text="取消"
                           @confirm="handleDelete(row)">
              <template #reference>
                <el-button size="small" plain type="danger" class="action-btn">删除</el-button>
              </template>
            </el-popconfirm>
            <el-button size="small" plain type="danger" class="action-btn">复购</el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
        background
        v-model:current-page="page"
        v-model:page-size="pageSize"
        :page-sizes="pageSizeNum"
        :total="totalNums"
        layout="total, sizes, prev, pager, next, jumper"
    >
    </el-pagination>

    <go-back/>
  </div>
</template>

<script setup>
import {
  getCurrentInstance,
  ref,
  reactive,
  onMounted,
  watch,
  computed
} from "vue"
import listMixins from "@mixins/hook/list"
import {
  useRouter
} from "vue-router"
import {
  CirclePlus,Search,Download
} from "@element-plus/icons-vue"
import GoBack from "@components/GoBack.vue"

const router = useRouter()
const {
  proxy
} = getCurrentInstance()

/**
 * minxin列表加载
 */
const {
  page,
  pageSizeNum,
  pageSize,
  loading,
  totalNums,
  searchParams,
  searchBtnLoading,
  apiPath,
  list,
  dialogFormRef,
  dialogShow,
  dialogForm,
  dialogParams,
  handleSearch,
  getData,
  handleAdd,
  handleEdit,
  resetDialogForm,
  handleAllSelected,
  submitDialogForm,
  closeDialog,
  handleAction,
  importData
} = listMixins()

apiPath.value = 'http://192.168.1.169:3000/master/productIndex.json';



onMounted(() => {
  getData()
})
const handleDelete=(row)=> {
  handleAction('admin/system/menu/delete', {
    mod_id: row.mod_id,
  })
}

const tabsActive = ref('all')
searchParams.status = computed(()=>{
  if(tabsActive.value == 'all'){
    return ''
  }
  return tabsActive.value
})
watch(tabsActive,()=>{
  getData()
})
const selectOptions = reactive({
  status:[
    {label:'销售中（120）',value:1},
    {label:'已售罄（0）',value:2},
    {label:'仓库中（545）',value:3}
  ],
  op_user_type: [
    {label:'管家',value:2},
    {label:'管理人员',value:3},
  ]
})
const toGoodsEdit = () =>{
  router.push({
    path: "/Goods/GoodsEdit",
    query: {

    }
  })
}

</script>

<style lang="less">


</style>